package com.loy.utils;

import java.util.Scanner;

public class Utilitys {
    private static Scanner scanner = new Scanner(System.in);


    /**
     * 功能：从键盘读取一个字符串并返回
     * @param limit
     * @return
     */
    public static String readString(int limit) {
        String value = "";
        while (scanner.hasNext()) {
            value = scanner.nextLine();
            if (value.length() < 1 || value.length() > limit) {
                System.out.print("输入长度（不大于" + limit + "），请重新输入：");
                continue;
            }
            break;
        }
        return value;
    }
}
